package com.junjiao.util.dao.paging;

import java.util.List;

/**
 * 分页查询结果集
 * 
 * @project jiaojun_util
 * @ClassName SearchResultBean.java
 * @author jiaojun
 * @email junjiao.j@gmail.com
 * @version v0.0.1
 * @date 2012-4-28
 */
public class SearchResultBean {

	private static final long serialVersionUID = 0xec1f47e163dd709L;
	/**
	 * 最大记录数
	 */
	private int maxRowCount;
	/**
	 * 最大页数
	 */
	private int maxPage;
	/**
	 * 结果集
	 */
	private List<?> data;
	/**
	 * 查询条件
	 */
	private SearchBean searchBean;

	public SearchResultBean() {
	}

	public long getMaxRowCount() {
		return maxRowCount;
	}

	public void setMaxRowCount(int maxRowCount) {
		this.maxRowCount = maxRowCount;
		searchBean.setTotalRecords(maxRowCount);
		countMaxPage();
	}

	private void countMaxPage() {
		if (searchBean != null) {
			if (maxRowCount % (int) searchBean.getRowsPerPage() == 0L)
				maxPage = maxRowCount / (int) searchBean.getRowsPerPage();
			else
				maxPage = maxRowCount / (int) searchBean.getRowsPerPage() + 1;
			searchBean.setTotalPages(maxPage);
		}
	}

	public long getMaxPage() {
		return maxPage;
	}

	public void setMaxPage(int maxPage) {
		this.maxPage = maxPage;
	}

	public List<?> getData() {
		return data;
	}

	public void setData(List<?> data) {
		this.data = data;
	}

	public SearchBean getSearcherBean() {
		return searchBean;
	}

	public void setSearchBean(SearchBean searcherBean) {
		searchBean = searcherBean;
	}
}
